package com.zzl;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.bind.Bindable;
import org.springframework.boot.context.properties.bind.Binder;
import org.springframework.context.ApplicationContext;

import java.util.List;


/**
 * @author: zhangzeli
 * @date 10:40 2018/5/19
 * <P></P>
 */
@SpringBootApplication
public class Application {
    public static void main(String[] args) {
        ApplicationContext context = SpringApplication.run(Application.class,args);
        Binder binder = Binder.get(context.getEnvironment());

        //绑定配置
        FooProperties foo = binder.bind("com.zzl", Bindable.of(FooProperties.class)).get();
        System.out.println(foo.getFoo());

        // 绑定List配置
        List<String> post = binder.bind("com.zzl.post", Bindable.listOf(String.class)).get();
        System.out.println(post);

        List<PostInfo> posts = binder.bind("com.zzl.posts", Bindable.listOf(PostInfo.class)).get();
        System.out.println(posts);
    }
}
